Find Maximum of Three Numbers

Theory:

To find the maximum of three numbers, we compare each number with the others and return the largest one.

Python Code:

def find_maximum(num1, num2, num3):
return max(num1, num2, num3)

# Taking input from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
maximum = find_maximum(num1, num2, num3)
print("Maximum of", num1, ",", num2, ", and", num3, "is:", maximum)

Example:

Enter the first number: 5

Enter the second number: 8

Enter the third number: 3

Maximum of 5 , 8 , and 3 is: 8

Example:

Enter the first number: 10

Enter the second number: 2

Enter the third number: 15

Maximum of 10 , 2 , and 15 is: 15

Code Explanation:

The function find_maximum(num1, num2, num3) takes three numbers as input and returns the maximum using Python's built-in max() function.

The example usage section demonstrates how to take input from the user for the three numbers, find the maximum, and print the result.